#include "cesium/stages/monitor.hpp"
#include "cesium/stages/filewriter.hpp"
#include "cesium/pipeline.hpp"

using namespace Cesium;

template<typename T>
class VariableDiskMonitor : public Pipeline {
public:
    VariableDiskMonitor(T* var, const std::string& filename) {
        FileWriterStage* writerStage = new FileWriterStage(filename);
        add(writerStage);

        monitorStage = new MonitorStage<T>(var, writerStage);
        add(monitorStage);

        writerStage->unref();
    }
    ~VariableDiskMonitor() {
        monitorStage->unref();
        monitorStage = NULL;
    }

    void record() {
        monitorStage->signal();
    }
private:
    MonitorStage<T>* monitorStage;
}; // class VariableDiskMonitor

int main(int argc, char** argv) {

    uint32 counter = 0;

    VariableDiskMonitor<uint32> monitor(&counter, "counter_monitor.bin");

    monitor.record();
    counter++;
    monitor.record();
    counter++;
    counter++;
    monitor.record();

    return 0;
}
